package dao

import (
	"errors"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/model"
	"user_srv/user"
)

// 权限添加
func PermissionsCreate(in *user.PermissionsCreateRequest) (*model.Permissions, error) {
	//接收参数
	var permission model.Permissions
	permission.PermissionName = in.PermissionsName
	permission.PermissionDescription = in.PermissionsDescription
	//添加
	if err := permission.Create(); err != nil {
		pkg.Warn("权限添加失败")
		return nil, errors.New("权限添加失败")
	}
	pkg.Warn("权限添加成功",
		zap.String("permission_name", permission.PermissionName))
	return &permission, nil
}
